﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
                    xmlns:dgx="urn:tom-englert.de/DataGridExtensions"
                    xmlns:themes="clr-namespace:tomenglertde.ResXManager.View.Themes"
                    xmlns:properties="clr-namespace:tomenglertde.ResXManager.View.Properties">

  <DataTemplate DataType="ContentControl" x:Key="{x:Static themes:ResourceKeys.MenuItemDropDownDataTemplate}">
    <StackPanel Orientation="Horizontal" Background="Transparent">
      <ContentPresenter Content="{Binding Header, RelativeSource={RelativeSource FindAncestor, AncestorType=MenuItem}}" />
      <Decorator Width="2" />
      <Path x:Name="Path" Data="M 0 0 L 3.5 4 L 7 0 Z" Fill="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" VerticalAlignment="Center" />
    </StackPanel>
    <DataTemplate.Triggers>
      <Trigger Property="IsMouseOver" Value="True">
        <Setter TargetName="Path" Property="Fill" Value="{DynamicResource {x:Static SystemColors.MenuHighlightBrushKey}}" />
      </Trigger>
    </DataTemplate.Triggers>
  </DataTemplate>

  <!-- Style for the clear button in the filter text box -->
  <Style x:Key="{x:Static themes:ResourceKeys.ColumnHeaderSearchTextBoxClearButtonStyleKey}" TargetType="Button">
    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="ButtonBase">
          <Border Background="Transparent">
            <Path x:Name="Path" Data="M0,0 L7,7 M0,7 L7,0" Stroke="{TemplateBinding Foreground}" HorizontalAlignment="Center" VerticalAlignment="Center" StrokeThickness="2" Margin="3" Opacity=".4" />
          </Border>
          <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
              <Setter TargetName="Path" Property="Opacity" Value=".7" />
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <!-- Style for a filter text box. The text box is only visible when it's hovered, focused or has a value.  -->
  <Style x:Key="{x:Static themes:ResourceKeys.ColumnHeaderSearchTextBoxStyleKey}" TargetType="TextBox">
    <Setter Property="MinWidth" Value="20" />
    <Setter Property="Margin" Value="4,0,2,0" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type TextBox}">
          <Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
            <DockPanel>
              <Button x:Name="clear" DockPanel.Dock="Right" Focusable="False" Style="{DynamicResource {x:Static themes:ResourceKeys.ColumnHeaderSearchTextBoxClearButtonStyleKey}}">
                <i:Interaction.Behaviors>
                  <dgx:ClearTextBoxOnButtonClickBehavior TextBox="{Binding RelativeSource={RelativeSource TemplatedParent}}" />
                </i:Interaction.Behaviors>
              </Button>
              <ScrollViewer x:Name="PART_ContentHost" Focusable="False" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" />
            </DockPanel>
          </Border>
          <ControlTemplate.Triggers>
            <Trigger Property="IsEnabled" Value="False">
              <Setter Property="Opacity" TargetName="border" Value="0.56" />
            </Trigger>
            <Trigger Property="IsMouseOver" Value="True">
              <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
            </Trigger>
            <Trigger Property="IsKeyboardFocused" Value="True">
              <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}" />
            </Trigger>
            <Trigger Property="Text" Value="">
              <Setter Property="Visibility" TargetName="clear" Value="Hidden" />
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Style.Triggers>
      <Trigger Property="Text" Value="">
        <Setter Property="Opacity" Value="0" />
      </Trigger>
      <Trigger Property="IsMouseOver" Value="True">
        <Setter Property="Opacity" Value="1" />
      </Trigger>
      <Trigger Property="IsFocused" Value="True">
        <Setter Property="Opacity" Value="1" />
      </Trigger>
    </Style.Triggers>
  </Style>

  <Style TargetType="Control" x:Key="{x:Static themes:ResourceKeys.IconStyleKey}">
    <Setter Property="HorizontalAlignment" Value="Right" />
    <Setter Property="VerticalAlignment" Value="Center" />
    <Setter Property="Template" Value="{DynamicResource {x:Static dgx:DataGridFilter.IconTemplateKey}}" />
    <Setter Property="Focusable" Value="False" />
    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}" />
  </Style>

  <Style TargetType="ToolTip" x:Key="{x:Static themes:ResourceKeys.ColumnHeaderGripperToolTipStyleKey}">
    <Setter Property="ContentTemplate">
      <Setter.Value>
        <DataTemplate>
          <TextBlock>
            <Run Text="{x:Static properties:Resources.ColumnHeaderGripperToolTip}" />
          </TextBlock>
        </DataTemplate>
      </Setter.Value>
    </Setter>
  </Style>

</ResourceDictionary>